#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    string addSpaces(string s, vector<int>& spaces) {
        string res;
        int j = 0;
        for (int i = 0; i < s.size(); ++i)
        {
            if (j < spaces.size() && i == spaces[j])
            {
                ++j;
                res += ' ';
            }
            res += s[i];
        }
        return res;
    }
};